emoji chooser: break out a helper function
authorMatthias Clasen <mclasen@redhat.com>
Mon, 20 Nov 2017 03:40:07 +0000 (22:40 -0500)
committerDaniel Boles <dboles@src.gnome.org>
Wed, 22 Nov 2017 19:11:31 +0000 (19:11 +0000)
This is just a small cleanup.

gtk/gtkemojichooser.c

index e06ecb8591d1f6a8be8875d82c8f4a78ce6ed572..232fc13eeba8a69baf8a00f63b64f603589142fe 100644 (file)
@@ -226,26 +226,12 @@ emoji_activated (GtkFlowBox      *box,
   g_free (text);
 }
 
-static void
-show_variations (GtkEmojiChooser *chooser,
-                 GtkWidget       *child)
+static gboolean
+has_variations (GVariant *emoji_data)
 {
-  GtkWidget *popover;
-  GtkWidget *view;
-  GtkWidget *box;
-  GVariant *emoji_data;
-  GtkWidget *parent_popover;
   GVariant *codes;
   int i;
   gboolean has_variations;
-  gunichar modifier;
-
-  if (!child)
-    return;
-
-  emoji_data = (GVariant*) g_object_get_data (G_OBJECT (child), "emoji-data");
-  if (!emoji_data)
-    return;
 
   has_variations = FALSE;
   codes = g_variant_get_child_value (emoji_data, 0);
@@ -260,7 +246,29 @@ show_variations (GtkEmojiChooser *chooser,
         }
     }
   g_variant_unref (codes);
-  if (!has_variations)
+
+  return has_variations;
+}
+
+static void
+show_variations (GtkEmojiChooser *chooser,
+                 GtkWidget       *child)
+{
+  GtkWidget *popover;
+  GtkWidget *view;
+  GtkWidget *box;
+  GVariant *emoji_data;
+  GtkWidget *parent_popover;
+  gunichar modifier;
+
+  if (!child)
+    return;
+
+  emoji_data = (GVariant*) g_object_get_data (G_OBJECT (child), "emoji-data");
+  if (!emoji_data)
+    return;
+
+  if (!has_variations (emoji_data))
     return;
 
   parent_popover = gtk_widget_get_ancestor (child, GTK_TYPE_POPOVER);